void main() {
  changeType();
  adjust();
  calculate();
  mutator();
  condition();
}

void changeType() {
  // 类型转换
  String str = '1';
  int num = int.parse(str);
  print(num);
  print(num is int);
  print(str is int);
}

void adjust() {
  // isEmpty 判断字符串是否为空
  String c = '';
  if (c.isEmpty) {
    print('c is null');
  }

  var number;
  if (number == null) {
    print('number is null');
  }

  // isNan判断是否有效值
  var nanNumber = 0 / 0;
  if (nanNumber.isNaN) {
    print('number is NAN');
  }
}

void calculate() {
  int a = 20;
  int b = 3;

  print(a + b); // 加
  print(a - b); // 减
  print(a * b); // 乘
  print(a / b); // 除
  print(a % b); // 取余
}

void mutator() {
  var a = null;
  // 如果a等于空的话，把33赋值给a
  a ??= 33;
  print(a);

  var b = 1;
  b ??= 33;
  print(b);
}

void condition() {
  var a = null;
  // 如果a等于空，把b赋值为100
  var b = a ?? 100;
  print(b);
}
